# helpers.py

def format_currency(value: float) -> str:
    """Format a float value as currency."""
    return f"${value:,.2f}"

def validate_risk_tolerance(risk_tolerance: str) -> bool:
    """Validate the risk tolerance level."""
    valid_levels = ["保守型", "稳健型", "平衡型", "成长型", "进取型"]
    return risk_tolerance in valid_levels

def calculate_portfolio_value(allocations: dict, total_value: float) -> dict:
    """Calculate the value of each asset class in the portfolio based on allocations."""
    return {asset: total_value * allocation for asset, allocation in allocations.items()}

def parse_financial_goals(goals: list) -> str:
    """Convert a list of financial goals into a formatted string."""
    return ', '.join(goals) if goals else "无财务目标"